<template>
	<view>
		<view class=""
			style="width: 90%;padding-top: 60rpx; margin: auto; height: 100rpx; display: flex; align-items: center; ">
			<image @click="toReturn" style="width: 50rpx; height: 50rpx;" src="../../../static/images/goBack.png">
			</image>
			<span style="margin-left: 20rpx;">客服</span>
		</view>
		<view class="" style="width: 90%;margin: auto;">

			<view class="image">
				<view class=""
					style="height: 27vh; left: 50%; transform: translate(-12%); width: 100%; margin: auto;  position: absolute; bottom: 0;">
					<p style=" color: #fff;">vx{{dataName.wechat_h}}</p>
					<img style=" width: 150rpx; height:150rpx ;margin-top: 30rpx;"
						:src="`${yourBaseURL}${dataName.wechat}`" alt="">
				</view>

			</view>
			<!-- <image style="width: 100%; height: 1000rpx; border-radius: 30rpx;"  src="../../../static/images/user/kefu1.jpg"></image> -->
			<view class="" style="display: flex; height: 100rpx;align-items: center; justify-content: space-around;">
				<p @click="saveImage"
					style="width: 200rpx; height: 80rpx; background: #f1f1f1; text-align: center;line-height: 80rpx; border-radius: 20rpx; color: #000;">
					保存图片</p>
				<p @click="copyWechat"
					style="width: 200rpx; height: 80rpx;background: linear-gradient(to right, #f67d34, #e5574b);text-align: center; line-height: 80rpx; border-radius: 20rpx; color: #fff;">
					复制微信添加</p>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getMyUserWeixin
	} from '@/http/api.js'
	export default {
		data() {
			return {
				dataName: {},
				yourBaseURL: 'http://hyxs.ychlkj.cn',
			};
		},
		onLoad() {
			this.MyUserWeixin()
		},
		methods: {
			MyUserWeixin() {
				getMyUserWeixin().then((res) => {
					this.dataName = res[1].data.data
					console.log(res[1].data.data, "kefu");
				})
			},

			// 返回上一页
			toReturn() {
				uni.navigateBack();
			},
			// 保存图片到相册
			saveImage() {
				console.log(this.yourBaseURL);
				console.log(this.yourBaseURL + this.dataName.wechat);
				uni.saveImageToPhotosAlbum({

					filePath: this.yourBaseURL + this.dataName.wechat, // 需要保存的图片文件路径，可以是本地路径或者网络路径
					success() {
						uni.showToast({
							title: '图片保存成功',
							icon: 'success'
						});
					},
					fail() {
						uni.showToast({
							title: '图片保存失败',
							icon: 'none'
						});
					}
				});
			},
			// 复制微信号并跳转到微信kehuduan
			copyWechat() {
				const wechatNumber = this.dataName.wechat_h; // 替换成实际的微信号
				
				uni.setClipboardData({
					data: wechatNumber,
					success() {
						plus.runtime.openURL("weixin://")
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.image {
		position: relative;
		height: 70vh;
		border-radius: 20px;
		border: 1px solid #ccc;
		background-size: 100%100%;
		background-image: url('../../../static/images/user/kefu1.png');
		background-repeat: no-repeat;
	}
</style>